package org.example.managementsystem.service;

import org.example.managementsystem.model.Production_Submission;
import org.example.managementsystem.repository.Production_SubmissionDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class Production_SubmissionService {
    private final Production_SubmissionDao productionSubmissionDao;

    @Autowired
    public Production_SubmissionService(Production_SubmissionDao productionSubmissionDao) {
        this.productionSubmissionDao = productionSubmissionDao;
    }

    public Production_Submission addProduction_Submission(Production_Submission productionSubmission) {
        int id = productionSubmissionDao.insertProduction_Submission(productionSubmission);
        productionSubmission.setSubmission_id(id);
        return productionSubmission;
    }

    public boolean updateProduction_Submission(Production_Submission productionSubmission) {
        return productionSubmissionDao.updateProduction_Submission(productionSubmission) > 0;
    }

    public boolean deleteProduction_Submission(int submissionId) {
        return productionSubmissionDao.deleteProduction_Submission(submissionId) > 0;
    }

    public Production_Submission getProduction_SubmissionById(int submissionId) {
        return productionSubmissionDao.getProduction_SubmissionById(submissionId);
    }

    public List<Production_Submission> getAllProduction_Submissions() {
        return productionSubmissionDao.getAllProduction_Submissions();
    }
    public List<Production_Submission> getAllApplicationUNPASS() {
        return productionSubmissionDao.getAllApplicationUNPASS();
    }
    public List<Production_Submission> getProduction_SubmissionsByPlanId(Long planId) {
        return productionSubmissionDao.getProduction_SubmissionByPlanId(planId);
    }
}